package com.example.myzhugezhaofang.adapter.newhouse;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.mvplibrary.adapter.BaseAdapter;
import com.example.mvplibrary.adapter.BaseViewHolder;
import com.example.myzhugezhaofang.R;
import com.example.myzhugezhaofang.bean.newhouse.SellTermBean;

import java.util.List;

public class SellAdapter extends BaseAdapter<SellTermBean.DataBean> {
    public onItemListener itemListener;

    public void setListener(onItemListener listener) {
        this.itemListener = listener;
    }

    public SellAdapter(List<SellTermBean.DataBean> datas, Context context, int layoutId) {
        super(datas, context, layoutId);
    }

    @Override
    protected void bindData(BaseViewHolder holder, SellTermBean.DataBean listBean, int position) {
        TextView text1 = holder.getView(R.id.tv_newhouse_sellterm_1);
        TextView text2 = holder.getView(R.id.tv_newhouse_sellterm_2);
        ImageView image = holder.getView(R.id.iv_newhouse_sellterm);
        /*if (position == 0) {
            image.setBackgroundColor(Color.WHITE);
        }*/
        String color = listBean.getColor();
        int i = Color.parseColor(color);
        text1.setText(listBean.getCount());
        text2.setText(listBean.getName());
        text1.setTextColor(i);
        text2.setTextColor(i);
        Glide.with(context).load(listBean.getImgurl()).into(image);

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                itemListener.onClick(position);
            }
        });
    }

    public interface onItemListener {
        void onClick(int n);
    }
}
